package utils.wallpaperCtrl;

import java.io.*;
import java.util.Scanner;

public class testC {
    public static Process process;
    public static void main(String[] args)  {
        /*String[] argss = new String[]{"/bin/bash", "-c", "xev -root"};
        Process process = Runtime.getRuntime().exec(argss);*/
        tt tt = new tt();
        tt.start();
        File file = new File("/bin");
        Runtime runtime = Runtime.getRuntime();
        try {
            process = runtime.exec("/bin/bash", null, file);
        } catch (IOException e) {
            e.printStackTrace();
        }
        OutputStream outputStream = process.getOutputStream();
        PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(outputStream));
        printWriter.println("xwinwrap -ni -o 1 -fs -s -st -sp -b -nf -- mpv --wid WID --no-audio --loop \"/home/zchroot/Pictures/vediowallpaper/test1.mp4\"\n");
        /*printWriter.println("xwinwrap -ni -o 0.3 -fs -s -st -sp -b -nf --wid = 0x07800007");*/
        printWriter.println("exit");
        printWriter.flush();
        BufferedReader bufferedReaderInput = new BufferedReader(new InputStreamReader(process.getInputStream()));
        BufferedReader bufferedReaderError = new BufferedReader(new InputStreamReader(process.getErrorStream()));
        while (true) {
            String line = null;
            try {
                line = bufferedReaderInput.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                break;
            }
            if (line != null) {
                System.out.println(line);
            }
        }
    }
}

class tt extends Thread {
    Runtime runtime;
    BufferedReader bufferedReaderInput;

    @Override
    public void run(){
        Scanner scanner = new Scanner(System.in);
        while (true){
            if (scanner.nextLine().equals("z")){
                testC.process.destroy();
                break;
            }
        }
    }
}



